{include file="public/header" /}
<style>
    .layui-rate {
        padding: 6px 5px 10px 0 !important;
    }

    .layui-rate .layui-inline {
        margin-right: 5px !important;
    }

    .layui-input-block {
        margin-left: 105px !important;
    }
</style>
<body>
<div class="x-body layui-anim">
    <form action="{:url('save')}" class="layui-form" id="form">
        <input type="hidden" name="id" value="{$info.id}">
        <fieldset class="layui-elem-field layui-field-title">
            <legend>退款状态</legend>
        </fieldset>
        <ul class="layui-timeline" style="padding-left: 30px">

            {if $info->getData('status') == 1}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" style="font-weight: bold;">
                        <span>等待商家同意</span>
                        <a href="javascript:;" class="layui-btn layui-btn-sm examineSuccess">同意</a>
                        <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger examineFail">不同意</a>
                    </div>
                </div>
            </li>
            {/if}
            {if $info->getData('status') == 2}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待商家同意</div>
                </div>
            </li>
            <li class="layui-timeline-item">
                <i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" style="font-weight: bold">等待寄回商品</div>
                </div>
            </li>
            {/if}
            {if $info->getData('status') == 3}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待商家同意</div>
                </div>
            </li>
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待寄回商品</div>
                </div>
            </li>
            <li class="layui-timeline-item">
                <i class="layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" style="font-weight: bold">
                        <span>等待商家确认收货</span>
                        <a href="javascript:;" class="layui-btn layui-btn-sm receiptSuccess">已收到货</a>
                        <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger receiptFail">未收到货</a>
                    </div>
                </div>
            </li>
            {/if}
            {if $info->getData('status') == 4}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待商家同意</div>
                </div>
            </li>
            {if $info.type == 2}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待寄回商品</div>
                </div>
            </li>
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待商家确认</div>
                </div>
            </li>
            {/if}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">退款成功</div>
                </div>
            </li>
            {/if}
            {if $info->getData('status') == 5}
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title">等待商家同意</div>
                </div>
            </li>
            <li class="layui-timeline-item">
                <i class="layui-icon layui-timeline-axis" style="color: red"></i>
                <div class="layui-timeline-content layui-text">
                    <div class="layui-timeline-title" style="font-weight: bold">未通过申请</div>
                </div>
            </li>
            {/if}
        </ul>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>退款信息</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">退款类型</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.type == 1?'仅退款':'退款退货'}" readonly="">
            </div>
            <label class="layui-form-label">退款金额</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.total}" readonly="">
            </div>
            <label class="layui-form-label">退款原因</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.reason}" readonly="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">退款编号</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.sn}" readonly="">
            </div>
            <label class="layui-form-label">申请会员</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.user.account}" readonly="">
            </div>
            <label class="layui-form-label">申请时间</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.create_time}" readonly="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">关联订单号</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.father.sn}" readonly="">
            </div>
            <label class="layui-form-label">货物状态</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.productStatusText}" readonly="">
            </div>

        </div>
        {if $info.type == 2}
        <div class="layui-form-item">
            <label class="layui-form-label">物流公司</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.express_title}" readonly="">
            </div>
            <label class="layui-form-label">物流单号</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input" value="{$info.express_code}" readonly="">
            </div>
        </div>
        {/if}
        <div class="layui-form-item">
            <label class="layui-form-label">补充描述</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" value="{$info.describe}" placeholder="补充描述" readonly="">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">描述图片</label>
            <div class="layui-input-block">
                <ul class="layui-upload-list showImages">
                    {foreach name="$info.images" id="v"}
                    <li class="flex-li">
                        <a href="{$v}" target="_blank"><img class="flex-img" src="{$v}"></a>
                    </li>
                    {/foreach}
                </ul>
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">退款商品</label>
            <div class="layui-input-inline" style="width: 80%;">
                <table class="layui-table layui-form" style="margin: 0px;">
                    <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>缩略图</th>
                        <th>单价</th>
                        <th>规格</th>
                        <th>数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    {foreach name="$info.product" item="v"}
                    <tr class="data_line">
                        <td>{$v.title}</td>
                        <td><a href="{$v.icon}" target="_blank"><img src="{$v.icon}" style="width: 30px"/></a></td>
                        <td>{$v.vip_price}</td>
                        <td>{$v.sku_name}</td>
                        <td>{$v.num}</td>
                    </tr>
                    {/foreach}
                    </tbody>

                </table>
            </div>
        </div>


    </form>
</div>
</body>
{include file="public/footer" /}
<script>
    $(".receiptSuccess").click(function () {
        layer.confirm('是否已收到货？', {title: '请确认'}, function (index) {
            layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                shade: 0.8,
                time: 99999
            });
            execute('{:url("orderRefund/receipt")}', 2)
        });
    })

    $(".receiptFail").click(function () {
        layer.confirm('是否未收到货？<br/>确认后退款订单状态将回退到等待用户上传物流状态', {title: '请确认'}, function (index) {
            layer.close(index);
            layer.prompt({title: '请填写原因', formType: 2}, function (pass, index) {
                layer.close(index);
                layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                    shade: 0.8,
                    time: 99999
                });
                execute('{:url("orderRefund/receipt")}', 3, pass)
            });
        });
    });


    $(".examineSuccess").click(function () {
        layer.confirm('确定要同意吗？', {title: '请确认'}, function (index) {
            layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                shade: 0.8,
                time: 99999
            });
            execute('{:url("orderRefund/examine")}', 2)
        });
    });

    $(".examineFail").click(function () {
        layer.confirm('确定要不同意退款申请吗？', {title: '请确认'}, function (index) {
            layer.close(index);
            layer.prompt({title: '请填写不同意原因', formType: 2}, function (pass, index) {
                layer.close(index);
                layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                    shade: 0.8,
                    time: 99999
                });
                execute('{:url("orderRefund/examine")}', 3, pass)
            });
        });
    });

    function execute(url, status, reject_msg = '') {
        $.post(url, {id: '{$info.id}', status: status, reject_msg: reject_msg}, function (data) {
            layer.closeAll();
            if (data.code == 1) {
                notify.success(data.msg, 1500, function () {
                    if (window.name != '') {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.window.location.reload();
                    } else {
                        window.location.reload();
                    }
                });

            } else {
                notify.error(data.msg);
            }
        });
    }
</script>
</html>